import React from "react"

class List extends React.Component {
    state = {
        arr: ["吃饭", "睡觉", "写代码"]
    }
    //key这个属性必须加到同级的兄弟元素上面
    render() {
        let lis = this.state.arr.map((item, index) => {
            return (
                <li key={index}>{item}</li>
            )
        })
        return (
            <fieldset>
                <legend>列表</legend>
                <ul>
                    {lis}
                </ul>
            </fieldset>
        )
    }
}
export default List